#include "../collections.hpp"


using lms::collections::Node;
using lms::collections::Queue;

template<class TEntity>
Queue<TEntity>::Queue()
{
      first = 0;
      last = 0;   
      length = 0;
}
template<class TEntity>
Node<TEntity>* Queue<TEntity>::getFirst()
{
      return first;               
}

template<class TEntity>
Node<TEntity>* Queue<TEntity>::getLast()
{
      return last;               
}

template<class TEntity>
int Queue<TEntity>::getLength()
{
      return length;    
}

template<class TEntity>
void Queue<TEntity>::enQueue(TEntity *entity)
{
    Node<TEntity> *tempNode = new Node<TEntity>();
    tempNode->setData(entity);
     
    if(first == 0)
    {
        first = tempNode;
        last = tempNode;         
    }else
    {
        last->setNext(tempNode);
        last = tempNode; 
    }    
    length++;
}

template<class TEntity>
Node<TEntity>* Queue<TEntity>::deQueue()
{
    if(first == 0)
    {
        return 0;         
    }    
    Node<TEntity> *tempNode = first;
    first = first->getNext();    
    return tempNode;
    length--;
}
